package com.rsk.service.impl;

import com.rsk.dao.SysCompanyTracksRepository;
import com.rsk.entity.SysCompanyTracks;
import com.rsk.service.SysCompanyTracksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

public class SysCompanyTracksServiceImpl implements SysCompanyTracksService {

    @Autowired
    private SysCompanyTracksRepository sysCompanyTracksRepository;

    @Transactional
    @Override
    public int delSysCompanyTracks(Long id, Long operatorUser) {
        return sysCompanyTracksRepository.delSysCompanyTracks(id,operatorUser);
    }

    @Transactional
    @Override
    public int saveSysCompanyTracks(Long id, Long companyId, String trackTheme,
                                    String trackContent, Date trackTime, String contactsUser,
                                    String contactsPhone, Long userId, Long operatorUser) {

        SysCompanyTracks companyTracks = new SysCompanyTracks();
        companyTracks.setId(id);
        companyTracks.setCompanyId(companyId);
        companyTracks.setTrackTheme(trackTheme);
        companyTracks.setTrackContent(trackContent);
        companyTracks.setTrackTime(trackTime);
        companyTracks.setContactsPhone(contactsPhone);
        companyTracks.setContactsUser(contactsUser);
        companyTracks.setUserId(userId);
        companyTracks.setOperatorUser(operatorUser);
        sysCompanyTracksRepository.saveAndFlush(companyTracks);
        return 1;
    }
}
